package com.gymjournal

class Gymnastic {
    static hasMany = [gymSets: GymSet]

    Note note
    GymnasticType gymnasticType
    String customGymnasticType
    List<GymSet> gymSets

    static constraints = {
        note(nullable: true)
        gymnasticType(nullable: true, validator: {gymnasticType, gymnastic ->
                gymnasticType == null ^ gymnastic.customGymnasticType == null
            }
        )
        customGymnasticType(nullable: true)
        gymSets(nullable: true)
    }

    @Override
    String toString() {
        gymnasticType != null ? gymnasticType : customGymnasticType
    }
}
